% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/latlon_from_naics.R
\name{latlon_from_naics}
\alias{latlon_from_naics}
\title{Find EPA-regulated facilities in FRS by NAICS code (industrial category)}
\usage{
latlon_from_naics(naics, children = TRUE, id_only = FALSE, ...)
}
\arguments{
\item{naics}{a vector of naics codes or query of titles of NAICS, or
a data.table with column named code, as with output of \code{\link[=naics_from_any]{naics_from_any()}}}

\item{children}{optional logical. set to FALSE to get only exact matches
rather than all facilities whose NAICS
starts with provided naics (or naics based on provided title).
Many facilities have only a longer more specific NAICS code
listed in the FRS, such as a 6-digit code, so if the category (e.g., 4-digit)
is queried then without children = TRUE one would not find all the sites
within that overall category.}

\item{id_only}{optional logical. Must set TRUE to get only regid instead of table}

\item{...}{passed to \code{\link[=naics_from_any]{naics_from_any()}}}
}
\value{
A data.table (not just data.frame) with columns called
lat, lon, REGISTRY_ID, NAICS, naics_found, naics_query (unless id_only parameter set TRUE).
naics_query is the input parameter that was used (that had been provided to this function as naics).
naics_found and NAICS are identical (redundant), and are the code found that
was listed in the \link{frs_by_naics} table, so it might be a subcategory (child)
of the naics_query term. For example, naics_query might be 33611 (5 digits)
and for one facility the NAICS and naics_found might be 336111 (a 6-digit code)
and for another facility they might be 336112.
}
\description{
Get lat lon, Registry ID, given NAICS industry code(s)
Find all EPA Facility Registry Service (FRS) sites with this/these NAICS code(s)
}
\details{
Important notes:
\itemize{
\item Finding the right NAICS and finding all the right sites by NAICS is complicated,
and requires understanding the NAICS codes system, the FRS data, and the EJAM functions.
See the discussion in the "Advanced" or other vignettes/articles.
\item Many FRS sites lack NAICS code!
\item Note the difference between children = TRUE and children = FALSE
\item The NAICS in the returned table may be a child NAICS not the NAICS used in the query! This may cause confusion if you are querying multiple parent NAICS and you want to analyze results by NAICS!
}

The functions like \code{\link[=regid_from_naics]{regid_from_naics()}}, \code{\link[=latlon_from_naics]{latlon_from_naics()}}, and \code{\link[=frs_from_naics]{frs_from_naics()}}
try to find EPA FRS sites based on naics codes or titles.

EPA also provides a \href{https://www.epa.gov/frs/frs-query#industrial}{FRS Facility Industrial Classification Search tool}
where you can find facilities based on NAICS or SIC.

See more about NAICS industry codes at \url{https://www.naics.com/search}
}
\examples{
\dontrun{
  regid_from_naics(321114)
  latlon_from_naics(321114)
  # latlon_from_naics(naics_from_any("cheese")[,code] )
  latlon_from_naics("cheese")
  head(latlon_from_naics(c(3366, 33661, 336611), id_only=TRUE))
  head(regid_from_naics(c(3366, 33661, 336611))
  head(regid_from_naics(3366, children = TRUE))
  # mapfast(frs_from_naics(336611)) # simple map
  
  # get name from one code
  naics_from_code(336)$name
  # get the name from each code
  mycode = c(33611, 336111, 336112)
  naics_from_code(mycode)$name
  # see counts of facilities by code (parent) and subcategories (children)
  naics_counts[NAICS \%in\% mycode, ]
  # see parent codes that contain each code
  naicstable[code \%in\% mycode, ]
  
  # how many were found via each naics code?
  found = latlon_from_naics(c(211,331))
  x = table( found$naics_found, found$naics_query)
  x = x[order(x[, 1],decreasing = T),]
  x
  }
}
\seealso{
\code{\link[=frs_from_naics]{frs_from_naics()}}  \code{\link[=frs_from_sic]{frs_from_sic()}} \code{\link[=latlon_from_sic]{latlon_from_sic()}} \code{\link[=regid_from_naics]{regid_from_naics()}} \code{\link[=naics_from_any]{naics_from_any()}}
}
